﻿using System;
using System.Collections.Generic;
using System.Text;
using Athena;
using Athena.Tools;
using Athena.Plugins;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using SystemsBiologyWorkbench = SBW;

namespace Athena.SBW
{
    public class SimulationPlugin: INonVisualTool
    {
        public static Simulator simulator = new SBWSimulator("edu.kgi.roadRunner", "sim");

        public SimulationPlugin()
        {
            try
            {
                if (!System.IO.Directory.Exists(SystemsBiologyWorkbench.Util.getRuntimeFilesDirectory()))
                    throw new Exception("SBW not installed");
                //new SystemsBiologyWorkbench.Module("BROKER");
                ToolManager.Instance.RegisterSimulationTool("SBW Simulator", this);
            }
            catch (Exception)
            {
            }
            _bHasContextMenuItems = false;
            _bHasMenuItems = false;
            _bRequiresNewToolWindow = false;
        }

        public override void SetupToolStrip(ToolStrip oStrip)
        {
            ToolStripButton oButton = new ToolStripButton();
            oButton.Text = "SBW Simulator";
            oButton.ToolTipText = "SBW Simulator";
            oButton.Click += new EventHandler(SimulateButton_Pressed);
            oStrip.Items.Add(oButton);
            _bHasContextMenuItems = false;
            _bHasMenuItems = false;
            _bRequiresNewToolWindow = false;
        }

        public override ToolManager.Order Order
        {
            get
            {
                return ToolManager.Order.FRONT;
            }
        }
        public void SimulateButton_Pressed(object sender, EventArgs e)
        {
            ToolManager.Instance.SelectSimulationTool(sender,simulator);
            ToolManager.Instance.StartSimulation();
        }
    }
}
